package account.bean;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import account.command.CommandException;
import account.command.GetDrlCommand;
import account.command.SaveDrlCommand;
import account.model.DrlModel;

@ManagedBean( name="drl")
@RequestScoped
public class DrlBean {
	
	private DrlModel drlModel;
	
	@PostConstruct
	public void create() {
		GetDrlCommand command = new GetDrlCommand();
		try {
			command.execute();
			this.drlModel = command.outModel;
		} catch (CommandException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public DrlModel getDrlModel() {
		return drlModel;
	}
	
	public String save() {
		
		SaveDrlCommand command = new SaveDrlCommand();
		command.inModel = drlModel;
		try {
			command.execute();
		} catch (CommandException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return "/index.xhtml";
		
	}
	
}
